package com.gpj.netty.application.client;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.UUID;

/**
 * @className NetWorkClient
 * @description BIO客户端代码
 * @author GPJ
 * @date 2021/11/30 17:02
 * @version 1.0
 **/
@Slf4j
public class NetWorkClient {
	public static void main(String[] args) throws IOException {
		Socket socket = new Socket("127.0.0.1", 9000);

		OutputStream out = socket.getOutputStream();
		out.write(("BIO请求访问" + UUID.randomUUID().toString()).getBytes());
		out.flush();

		byte[] bytes = new byte[1024];
		int num = socket.getInputStream().read(bytes);
		log.info("接收到服务端的数据：{}", new String(bytes, 0, num));

		socket.close();
	}
}
